/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */

#ifndef _VOICE_AI_H_
#define _VOICE_AI_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <voice_def.h>

typedef struct __voice_cts_ops {
    int cache_cts;                  // number of cts_ms to cache, if 0 no cache is used
    int (*init)(void *priv);
    int (*deinit)(void *priv);
    int (*start_alg_tsk)(void *priv, void (*fn)(void *), void *arg);
    int (*set_param)(void *priv, void *param);
    int (*get_kws_data)(void *priv, void **data, size_t *data_len);
    int (*get_kw_map)(void *priv, voice_kwmap_t **kw_map);
    int (*wkvc_stat)(void *priv, int is_playing);
    int (*aec)(void *priv, void *mic, void *ref, int ms, void *out);
    int (*vad)(void *priv, void *mic, void *ref, int ms, void **out, size_t *out_len);
    int (*kws)(void *priv, void *mic, void *ref, int ms, void *out);
    int (*asr)(void *priv, void *vad_data, int ms);
} voice_cts_ops_t;

/**
 * @brief  voice init
 * @param  [in] priv        : argv back to cb
 * @param  [in] ops         : ai algorithm ops
 * @return !NULL on success, NULL on failed
 */
voice_t *voice_ai_init(void *priv, voice_cts_ops_t *ops);

/**
 * @brief  voice ai deinit
 * @param  [in] v          : voice handle
 */
void voice_ai_deinit(voice_t *v);

/**
 * @brief  voice pcm backflow control
 * @param  [in] v           : voice handle
 * @param  [in] cmd         : message cmd
 * @param  [in] data        : message data
 * @param  [in] len         : message date len
 * @param  [in] sync        : 0:async  1:sync
 * @return 0 on success, -1 on failed
 */
int voice_ai_msg_send(voice_t *v, int cmd, void *data, int len, int sync);

#ifdef __cplusplus
}
#endif

#endif